<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .box {
            position: relative;
            width: 400px;
            border-bottom: 1px solid #ccc;
            margin: 100px auto;
        }
        
        .box input {
            width: 370px;
            height: 30px;
            border: 0;
            outline: none;
        }
        
        .box img {
            position: absolute;
            top: 6px;
            right: 2px;
            width: 24px;
            cursor: pointer;
        }
        
        #eye{
            display: none;
        }
    </style>
</head>

<body>
    <div class="box">
        <label for="pwd">
            <img src="images/eyes.png" id="eye">
            <img src="images/close.png" id="close">
        </label>
        <input type="password" name="" id="pwd">
    </div>
    <script>
        var imgEye = document.getElementById('eye');
        var imgClose = document.getElementById('close');
        var input = document.getElementById('pwd');

        imgClose.addEventListener('click',() => {
            imgClose.style.display = 'none';
            imgEye.style.display = 'inline-block';
            input.type = 'text';
        },false);
        
        imgEye.addEventListener('click',() => {
            imgEye.style.display = 'none';
            imgClose.style.display = 'inline-block';
            input.type = 'password';
        },false);
        
    </script>
</body>

</html>